import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

chrome_driver = webdriver.Chrome()
chrome_driver.maximize_window()
cookiestr = ""

chrome_driver.get("https://www.huxiu.com")
chrome_driver.find_element(By.XPATH, '//*[@id="header-nav"]/nav/div/div[3]/div[2]/img')
login_control = chrome_driver.find_element(By.XPATH, '//*[@id="header-nav"]/nav/div/div[3]/div[2]/img')
login_control.click()
time.sleep(2)
chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[2]/span')
login_control1 = chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[2]/span')
login_control1.click()
time.sleep(2)

control_num = chrome_driver.find_element(By.XPATH,
                                         '//*[@id="app"]/section/div[2]/div/div[1]/div[1]/div[1]/div[2]/input')
control_num.send_keys("19559917806")
time.sleep(1)
control_pwd = chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[1]/div[2]/div/input')
control_pwd.send_keys("Gx583357384")
time.sleep(1)
control_dw = chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/button')
control_dw.click()
time.sleep(2)
'''


WebDriverWait(chrome_driver, 15).until(
    EC.element_to_be_clickable((By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[2]/span')))
idandpwd_control = chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[2]/span')
idandpwd_control.click()
WebDriverWait(chrome_driver, 15).until(
    EC.element_to_be_clickable((By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[1]/div/input')))
id_control = chrome_driver.find_element(By.XPATH, '//*[@id="app"/section/div[2]/div/div[1]/div[1]/div/input')
WebDriverWait(chrome_driver, 15).until(
    EC.element_to_be_clickable((By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[2]/div/input')))
pwd_control = chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/div[1]/div[2]/div/input')
id_control.send_keys("用户名")
pwd_control.send_keys("密码")
WebDriverWait(chrome_driver, 15).until(
    EC.element_to_be_clickable((By.XPATH, '//*[@id="app"]/section/div[2]/div/button')))
login_button_control = chrome_driver.find_element(By.XPATH, '//*[@id="app"]/section/div[2]/div/button')
login_button_control.click()
'''
